<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>老人信息后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">


    <link rel="stylesheet" href="/css/modules/code.css">
    <link rel="stylesheet" href="/css/modules/laydate/default/laydate.css">
    <link rel="stylesheet" href="/css/modules/layer/default/layer.css">
    <link rel="stylesheet" href="/css/layui.css">

    <#include "common/common-head.html"/>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">居家养老系统后台管理</div>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="/index">老人信息</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/order/docList">医生预约情况</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/order/volList">志愿者预约情况</a>
                </li>

            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <#--<a href="/elderly/add" class="layui-btn">添加老人</a>-->
        <table class="layui-hide" id="demo" lay-filter="demo"></table>
        <div class="demoTable">
            <form>
                <div class="layui-inline">
                    <input class="layui-input" name="word" id="demoReload" autocomplete="off" value="${word!}">
                </div>
                <button class="layui-btn" data-type="reload" type="submit">搜索</button>
            </form>
        </div>
    </div>
    <div class="layui-footer">

        © 居家养老系统 Copyright 钱坤
    </div>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>


<script>

    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;

    });


    layui.use('table', function () {
        var table = layui.table;

        //展示已知数据
        table.render({
            elem: '#demo',
            cols: [[ //标题栏
                {field: 'no', title: '编号', width: 80}
                , {field: 'username', title: '姓名', width: 100}
                , {field: 'sex', title: '性别', width: 60}
                , {field: 'age', title: '年龄', width: 60}
                , {field: 'phone', title: '联系方式', width: 130}
                , {field: 'address', title: '家庭地址', minWidth: 150}
                , {field: 'status', title: '当前身体状况', minWidth: 150}
                , {field: 'history', title: '过往病史/过敏史', width: 150}
                , {field: 'experience', title: '操作', width: 80, toolbar: '#barDemo'}
            ]],
            url:"/elderly/list?word=${word!}"
            //data: database
            //,skin: 'line' //表格风格
            , even: true
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['count'] //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                ,groups: 1 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页

            }
            //,limits: [5, 7, 10]
            //,limit: 5 //每页默认显示的数量
        });
    });

    var table = layui.table;
    table.on('tool(demo)', function (obj) {

        var data = obj.data;
        if (obj.event === 'detail') {
            layer.msg('ID：' + data.id + ' 的查看操作');
        } else if (obj.event === 'del') {
            layer.confirm('真的删除行么', function (index) {
                console.log(data.id);
                location.href = "/elderly/del/"+data.id;
            });
        } else if (obj.event === 'edit') {
            layer.alert('编辑行：<br>' + JSON.stringify(data))
        }
    });

    $('.demoTable .layui-btn').on('click', function () {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
</script>
</body>
</html>
